#include "Filelist.h"

Filelist::Filelist(QWidget *parent)
    : QListWidget(parent)
{

}

bool Filelist::dropMimeData(int index, const QMimeData *data, Qt::DropAction action)
{
    QList <QUrl> urlList;
    QListWidgetItem *item;
    QFileInfo info;
    QString fName;

    setStyleSheet("");
    urlList = data->urls(); // retrieve list of urls

    foreach(QUrl url, urlList) // iterate over list
    {
        fName = url.toLocalFile();

        QList<QListWidgetItem *> items = findItems(fName,Qt::MatchFixedString);
        if(items.isEmpty())
        {
            item = new QListWidgetItem(fName);
            addItem(item);
        }
    }

    return true;
}


QStringList Filelist::mimeTypes () const
{
    QStringList qstrList;
    // list of accepted mime types for drop
    qstrList.append("text/uri-list");
    return qstrList;
}


Qt::DropActions Filelist::supportedDropActions () const
{
    // returns what actions are supported when dropping
    return Qt::CopyAction | Qt::MoveAction;
}
